<?php

class RecordModel extends Model
{
	private $record_arr = array('Gold', 'Lotto', 'Prize');
	
	public function onAdd($type, $params){
		if(!in_array(ucfirst($type), $this->record_arr)){
			return false;			
		}else{
			$modelName = 'Record'.$type;
			$result = M($modelName)->add($params);
			return $result;
		}
	}
	
	public function oneDayLottoTimes($u_id){
		$_model = M('RecordLotto');
		list($y, $m, $d) = explode('-', date('Y-m-d'));
		$stime = mktime(0, 0, 0, $m, $d, $y);
		$etime = mktime(23, 59, 59, $m, $d, $y);
		$_rel['rel_time'] = array(array('gt', $stime),array('lt', $etime),'AND');
		$_rel['u_id'] = $u_id;
		$count = $_model->where($_rel)->count();
		return $count;
	}
	
	public function getLottoDynamic(){
		$_model = M('RecordLotto');
		
		$_join = ' ws_user on ws_user.u_id=ws_record_lotto.u_id ';
		
		$_con['lo_id'] = array('gt', 0);
		
		$pk = $_model->getPk();
		$_order = $pk.' desc';
		
		$_limit = 10;
		
		$list = $_model->join($_join)->where($_con)->limit($_limit)->order($_order)->select();
		return $list;
	}
	
	
	
	
}



?>